# crawler/models.py
from django.db import models
import django.utils.timezone as timezone


class Crawler(models.Model):


	id = models.AutoField(primary_key=True, editable=False)
	address = models.CharField(verbose_name='地址链接',null=True,max_length=255)
	image = models.CharField(verbose_name='图片地址',null=True,max_length=255)
	name = models.CharField(verbose_name='名称',null=True,max_length=255)
	price = models.CharField(verbose_name='价格',null=True,max_length=50)
	commit = models.CharField(verbose_name='评论',null=True,max_length=50)
	shop = models.CharField(verbose_name='店铺',null=True,max_length=50)
	keyboard = models.CharField(verbose_name='关键字',max_length=50, null=True)

	class Meta:
		verbose_name = '爬虫数据表'
		verbose_name_plural = verbose_name


class MonitoringGoods(models.Model):


	id = models.AutoField(primary_key=True, editable=False)
	address = models.CharField(verbose_name='地址链接',null=True,max_length=255)
	image = models.CharField(verbose_name='图片地址',null=True,max_length=255)
	name = models.CharField(verbose_name='名称',null=True,max_length=255)
	shop = models.CharField(verbose_name='店铺',null=True,max_length=50)
	keyboard = models.CharField(verbose_name='关键字',max_length=50, null=True)
	crawler = models.ForeignKey("Crawler", verbose_name='爬虫数据表', on_delete=models.SET_NULL, null=True)

	class Meta:
		verbose_name = '监控商品表'
		verbose_name_plural = verbose_name


class MonitoringGoodsPriceHistory(models.Model):


	id = models.AutoField(primary_key=True, editable=False)
	price = models.CharField(verbose_name='价格',null=True,max_length=50)
	add_time = models.DateTimeField(verbose_name='日期',auto_now_add=True)
	monitoring_goods = models.ForeignKey("Crawler", verbose_name='监控商品表', on_delete=models.SET_NULL, null=True)

	class Meta:
		verbose_name = '监控商品历史价格表'
		verbose_name_plural = verbose_name